home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Offline Browsing / HTTrack.exe / data1.cab / Sources / src / htsrobots.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-04-28  |  3.4 KB  |  118 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: httrack.c subroutines:                                 */
  34. /*       robots.txt (website robot file)                        */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38.  
  39. #include "htsrobots.h"
  40.  
  41. /* specific definitions */
  42. #include "htsbase.h"
  43. #include "htslib.h"
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. /* END specific definitions */
  47.  
  48.  
  49. // -- robots --
  50.  
  51. // fil="" : vΘrifier si rΦgle dΘja enregistrΘe
  52. int checkrobots(robots_wizard* robots,char* adr,char* fil) {
  53.   while(robots) {
  54.     if (strfield2(robots->adr,adr)) {
  55.       if (fil[0]) {
  56.         int ptr=0;
  57.         char line[250];
  58.         if (strnotempty(robots->token)) {
  59.           do {
  60.             ptr+=binput(robots->token+ptr,line,200);
  61.             if (line[0]=='/') {    // absolu
  62.               if (strfield(fil,line)) {                 // commence avec ligne
  63.                 return -1;        // interdit
  64.               }
  65.             } else {    // relatif
  66.               if (strstrcase(fil,line)) {
  67.                 return -1;
  68.               }
  69.             }
  70.           } while( (strnotempty(line)) && (ptr<(int) strlen(robots->token)) );
  71.         }
  72.       } else {
  73.         return -1;
  74.       }
  75.     }
  76.     robots=robots->next;
  77.   }
  78.   return 0;
  79. }
  80. int checkrobots_set(robots_wizard* robots,char* adr,char* data) {
  81.   if (((int) strlen(data)) > 999) return 0;
  82.   while(robots) {
  83.     if (strfield2(robots->adr,adr)) {    // entrΘe existe
  84.       strcpy(robots->token,data);
  85. #if DEBUG_ROBOTS
  86.         printf("robots.txt: set %s to %s\n",adr,data);
  87. #endif
  88.       return -1;
  89.     }
  90.     else if (!robots->next) {
  91.       robots->next=(robots_wizard*) calloc(1,sizeof(robots_wizard));
  92.       if (robots->next) {
  93.         robots->next->next=NULL;
  94.         strcpy(robots->next->adr,adr);
  95.         strcpy(robots->next->token,data);
  96. #if DEBUG_ROBOTS
  97.         printf("robots.txt: new set %s to %s\n",adr,data);
  98. #endif
  99.       }
  100. #if DEBUG_ROBOTS
  101.       else
  102.         printf("malloc error!!\n");
  103. #endif
  104.     }
  105.     robots=robots->next;
  106.   }
  107.   return 0;
  108. }
  109. void checkrobots_free(robots_wizard* robots) {
  110.   if (robots->next) {
  111.     checkrobots_free(robots->next);
  112.     freet(robots->next);
  113.     robots->next=NULL;
  114.   }
  115. }
  116.  
  117. // -- robots --
  118.